﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;
/// <summary>
/// Summary description for HoadonBLL
/// </summary>
public class HoadonBLL
{
    //public static int Datdonhang()
    //{ 
        
    //}
    public static List<Gia> giaselect()
    {
        DBHelp help = new DBHelp();
        List<Gia> listgia = new List<Gia>();
        List<SqlParameter> listparam = new List<SqlParameter>();
        SqlDataReader ds = help.DataReaders("giaselect", listparam);
        if (ds.HasRows)
        {
            while (ds.Read())
            {
                Gia gias= new Gia();
                gias.Soluong = Convert.ToInt32(ds[0].ToString());
                gias.Giathe = ds[1].ToString();
                listgia.Add(gias);
            }
        }
        return listgia;

    }
    public static int DonhangInsert(Donhang dh)
    {
        DBHelp help = new DBHelp();
        SqlParameter param;
        List<SqlParameter> listparam = new List<SqlParameter>();
        param = new SqlParameter("@hovaten", SqlDbType.VarChar);
        param.Value = dh.Tennguoinhanthe;
        listparam.Add(param);

        param = new SqlParameter("@email", SqlDbType.VarChar);
        param.Value = dh.Diachiemail;
        listparam.Add(param);

        param = new SqlParameter("@diachi", SqlDbType.VarChar);
        param.Value = dh.Diachinguoinhanthe;
        listparam.Add(param);

        param = new SqlParameter("@sodienthoai", SqlDbType.VarChar);
        param.Value = dh.Sodienthoai;
        listparam.Add(param);

        param = new SqlParameter("@tinhthanhpho", SqlDbType.VarChar);
        param.Value = dh.Tinhthanhpho;
        listparam.Add(param);

        param = new SqlParameter("@thoigian", SqlDbType.DateTime);
        param.Value = DateTime.Today;
        listparam.Add(param);

        param = new SqlParameter("@soluong", SqlDbType.Int);
        param.Value = dh.Soluongthe;
        listparam.Add(param);

        param = new SqlParameter("@tongtien", SqlDbType.VarChar);
        param.Value = dh.Tongtien;
        listparam.Add(param);
        int a=help.Execute_Querry("donhangInsert",listparam);
        return a;
    }
}
